package com.cap2.config;

import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.FilterType;


//扫描
//

//@ComponentScan value:指定要扫描的包
//excludeFilters = Filter[] 指定扫描的时候按照什么规则排除那些组件
//includeFilters = Filter[] 指定扫描的时候只需要包含哪些组件
//useDefaultFilters = false 默认是true,扫描所有组件，要改成false
//－－－－扫描规则如下
//FilterType.ANNOTATION：按照注解
//FilterType.ASSIGNABLE_TYPE：按照给定的类型；比如按BookService类型
//FilterType.ASPECTJ：使用ASPECTJ表达式
//FilterType.REGEX：使用正则指定
//FilterType.CUSTOM：使用自定义规则，自已写类，实现TypeFilter接口


//Component.class, Repository.class, Service.class, Controller.class,
//,excludeFilters = {@ComponentScan.Filter(type = FilterType.ASSIGNABLE_TYPE,classes = OrderDao.class)}
//配置类

/*
@ComponentScan(value = "com.cap2.*",excludeFilters = {
        @ComponentScan.Filter(type = FilterType.ASSIGNABLE_TYPE ,classes = {Configuration.class})},useDefaultFilters=true)//useDefaultFilters默认是true,扫描带有@Component ro @Repository ro @Service ro @Controller 的组件，要改成false,使用自定义扫描范围


@ComponentScan(value = "com.cap2",includeFilters = {@ComponentScan.Filter(type = FilterType.ANNOTATION, classes = {Controller.class})},useDefaultFilters =true)

@ComponentScan(value = "com.cap2",excludeFilters = {
        @ComponentScan.Filter(type = FilterType.CUSTOM,classes = {TypeFilter.class})
},useDefaultFilters = false)
*/

/**
 * ComponentScan 扫描组件
 * value 包扫描的路径
 * includeFilters = Filter[] 指定扫描的时候只需要包含哪些组件
 * type = FilterType.ANNOTATION 按照注解
 * classes = {Service.class} 注解里面的Service
 * useDefaultFilters = false 使用自定义扫描范围要改成false
 * 只扫描我com.cap2下的带有@Service注解的类
 *
 * @Configuration
 * @ComponentScan(value = "com.cap2",excludeFilters = {@ComponentScan.Filter(
 *         type = FilterType.ANNOTATION,classes = {Service.class}
 * )},useDefaultFilters = false)错误的例子
 */

@Configuration
@ComponentScan(value = "com.cap2",includeFilters = {@ComponentScan.Filter(
        type = FilterType.CUSTOM,classes = {TypeFilter.class}
)},useDefaultFilters = false)
public class Cap2MainConfig {
   /* @Bean
    public Person person01() {
        return new Person("james", 20);
    }*/
}
